package com.hex.ds.hdtp.core.web.script.common.controller;

import com.hex.bigdata.hbda.annotation.Log;
import com.hex.ds.hdtp.core.app.script.common.service.IScriptTableConsanguinityService;
import com.hex.ds.hdtp.core.web.script.common.converter.IScriptTableConsanguinityVoConverter;
import com.hex.ds.hdtp.core.web.script.common.vo.ScriptTableConsanguinityVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Package: com.hex.ds.hdtp.core.web.test.controller
 * @ClassName ScriptTableConsanguinityController
 * @Description: 脚本表血缘-WEB接口
 * @Author: wz.li
 * @Date 2023/8/3 11:15
 * @Version v2.0.2
 **/
@Slf4j
@RestController
@Api(tags = "04-脚本测试：血缘")
@RequestMapping("/api/script/table/consanguinity")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptTableConsanguinityController {

    private final IScriptTableConsanguinityService scriptTestConsanguinityService;

    private final IScriptTableConsanguinityVoConverter converter;

    /*
     * @Method: add <br>
     * @Param: [scriptTestConsanguinityVo] <br>
     * @Return: org.springframework.http.ResponseEntity <br>
     * @Description：新增<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 17:23 <br>
     * @Version： V2.0.2<br>
     */
    @Log("数据测试脚本血缘-新增")
    @PostMapping
    @ApiOperation("带数据测试任务-新增")
    public ResponseEntity add(@RequestBody ScriptTableConsanguinityVo scriptTableConsanguinityVo) {
        log.info("进入到【ScriptDataTestTaskController.add】方法,参数：{}", scriptTableConsanguinityVo.toString());
        scriptTestConsanguinityService.add(converter.toScriptTestConsanguinityRequestDto(scriptTableConsanguinityVo));
        return ResponseEntity.ok("新增成功");
    }

    /*
     * @Method: delete <br>
     * @Param: [pkId] <br>
     * @Return: org.springframework.http.ResponseEntity <br>
     * @Description：删除<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 17:23 <br>
     * @Version： V2.0.2<br>
     */
    @Log("数据测试脚本血缘-删除")
    @DeleteMapping
    @ApiOperation("带数据测试任务-删除")
    public ResponseEntity delete(@RequestBody ScriptTableConsanguinityVo scriptTableConsanguinityVo) {
        log.info("进入【ScriptDataTestTaskController.delete】方法,参数：" + scriptTableConsanguinityVo.toString());
        scriptTestConsanguinityService.removeByTableName(converter.toScriptTestConsanguinityRequestDto(scriptTableConsanguinityVo));
        return ResponseEntity.ok("删除成功");
    }
}
